//导航栏
if (sessionStorage.openid == "" || sessionStorage.openid == null) {
    window.location.href = "login.html"
}
Vue.component('navbars', {
    props: ['acv'],
    template: '<div id="navbar" class="navbar-collapse collapse">' +
        '<ul class="nav navbar-nav" style="float:none">' +
        '<li v-for="(nav,index) in navs" :class="[acv.number == index?active:null]">' +
        '<a :href="nav.url">&nbsp;&nbsp;&nbsp;{{nav.name}}&nbsp; &nbsp;&nbsp;</a></li>' +
        '<li @click="goout()" class="pull-right" style="margin-right:20px">' +
        '<a href="login.html">&nbsp;&nbsp;&nbsp;退出&nbsp; &nbsp;&nbsp;</a></li>' +
        '<li class="pull-right">' +
        '<a href="./ebb-admin/index.html">&nbsp;&nbsp;&nbsp;后台&nbsp; &nbsp;&nbsp;</a></li>' +
        '</ul>' +
        '</div>',
    data: function() {
        return {
            navs: [{ name: '首页', url: 'index.html' },
                { name: '数据管理', url: 'dataManage.html' },
                { name: '数据分析', url: 'analysis.html' },
                { name: 'GIS', url: 'gis.html' },
                { name: '数据报告', url: 'dataReport.html?years=2017&quarter=1' }
            ],
            active: 'active'
        }
    },
    methods: {
        goout: function() {
            window.sessionStorage.openid = "";

        }
    }


})


Vue.component('managenav', {
    props: ['dsa'],
    template: '<div class="col-sm-3 col-md-2 sidebar">' +
        '<div v-for="nd in navs"><div class="nav-title" style="overflow:hidden;">' +
        '<a :href="nd.url" class="pull-left"><i class="glyphicon" :class="nd.icon"></i>  {{nd.tittle}}</a>' +
        '</div>' +
        '<div id="collapseOne" class="panel-collapse collapse in">' +
        '<ul class="nav nav-sidebar">' +
        '<li v-for="ns in nd.child" class="tree" :style="dsa==ns.name?backgrounds:null" :class="ns.last==1?lchild:null">' +
        '<a :href="ns.urls">{{ns.name}}</a>' +
        '</li>' +
        '</ul>' +
        '</div></div></div>',
    data: function() {
        return {
            backgrounds: 'background-color:#e1e1e1;',
            navs: [{
                    tittle: '平台管理',
                    url: 'platformManage.html',
                    icon: 'glyphicon-cloud',
                    child: [
                        { name: '第三方平台', urls: 'platformManage.html?tab=tab1', last: 0 },
                        { name: '自建平台', urls: 'platformSelf.html?tab=tab2', last: 0 },
                        { name: '电商综合服务站', urls: 'siteManage.html?tab=tab1', last: 0 },
                        { name: '电商企业', urls: 'platformCop.html', last: 1 }
                    ]
                },
                {
                    tittle: '物流管理',
                    url: 'logisticsManage.html',
                    icon: 'glyphicon-plane',
                    child: [
                        { name: '物流', urls: 'logisticsManage.html', last: 1 },
                        /*{name:'物流',urls:'logisticsManage.html#tab2',last:1}
                         */
                    ]
                },
                /*{
                 tittle:'服务站点管理',
                 url:'siteManage.html#tab1',
                 icon:'glyphicon-tree-deciduous',
                 child:[
                 {name:'代买',urls:'siteManage.html?tab=tab1',last:0},
                 {name:'代卖',urls:'siteManage.html?tab=tab2',last:1}
                 ]
                 },*/
                {
                    tittle: '培训管理',
                    url: 'trainManage.html',
                    icon: 'glyphicon-dashboard',
                    child: [
                        { name: '电商培训', urls: 'trainManage.html#tab1', last: 1 }
                    ]
                },
                {
                    tittle: '产品/产业管理',
                    url: 'productManage.html',
                    icon: 'glyphicon-asterisk',
                    child: [
                        { name: '产品管理', urls: 'productManage.html#tab1', last: 1 }
                    ]
                },
            ],
            lchild: 'last-child'
        }
    }


});

Vue.component('fxnav', {
    props: ['fx'],
    template: '<ul class="nav nav-sidebar nav-sparse">' +
        '<li v-for="(nav,index) in navs" :class="[fx == index?active:null]">' +
        '<a :href="nav.url">{{nav.name}}</a>' +
        '</li></ul>',
    data: function() {
        return {
            navs: [
                { name: '店铺分析', url: 'analysis.html' },
                { name: '物流分析', url: 'logistics.html' },
                { name: '培训分析', url: 'train.html' },
                { name: '服务站点分析', url: 'site.html' },
                { name: '交易汇总分析', url: 'transaction.html' },
                { name: '店铺TOP10分析', url: 'shop.html' },
                { name: '产品TOP10分析', url: 'product.html' }


            ],
            active: 'active'
        }
    }

});


Vue.component('datanav', {
    props: ['ds'],
    template: '<div class="col-sm-3 col-md-2 sidebar">' +
        '<div v-for="nd in navs"><div class="nav-title" style="overflow:hidden;">' +
        '<a :href="nd.url" class="pull-left">  {{nd.tittle}}</a>' +
        '</div>' +
        '<div id="collapseOne" class="panel-collapse collapse in">' +
        '<ul class="nav nav-sidebar">' +
        '<li v-for="ns in nd.child" class="tree" :style="ds==ns.name?backgrounds:null" :class="ns.last==1?lchild:null">' +
        '<a :href="ns.urls">{{ns.name}}</a>' +
        '</li>' +
        '</ul>' +
        '</div></div></div>',
    data: function() {
        return {
            backgrounds: 'background-color:#e1e1e1;',
            navs: [
                // {
                //     tittle: '数据报表',
                //     url: 'dataReport.html',
                //     child: [
                //         { name: '平台报表', urls: 'platformdata.html', last: 0 },
                //         { name: '物流报表', urls: 'logisticsdata.html', last: 0 },
                //         { name: '服务站点报表', urls: 'sitedata.html', last: 1 },
                //         // {name:'产品/产业报表',urls:'platformdata.html',last:1}
                //     ]
                // },
                {
                    tittle: '最新季报',
                    url: 'dataReport.html',
                    child: [
                        { name: '2017第1季度', urls: 'dataReport.html', last: 0 },
                        { name: '2017第4季度', urls: 'dataReport.html', last: 0 },
                        { name: '2017第3季度', urls: 'dataReport.html', last: 0 },
                        { name: '2017第2季度', urls: 'dataReport.html', last: 1 }
                    ]
                },
                {
                    tittle: '最新年报',
                    url: 'annalsdata.html',
                    icon: 'glyphicon-tree-deciduous',
                    child: [
                        { name: '2017上半年', urls: 'annalsdata.html', last: 0 },
                        { name: '2017全年', urls: 'annalsdata.html', last: 1 }
                    ]
                }
            ],
            lchild: 'last-child'
        }
    },
    mounted: function() {
        this.dataPort();
        this.yearPort();
    },
    methods: {
        dataPort: function() {
            var dates = new Date();
            var year = dates.getFullYear();
            var month = dates.getMonth() + 1;
            var childs = [];
            if (year >= 2017) {
                for (var i = 0; i <= (year - 2017); i++) {
                    if (i + 2017 < year) {
                        for (var j = 0; j < 4; j++) {
                            childs.push({ name: (2017 + i) + '第' + (j + 1) + '季度', urls: 'dataReport.html?years=' + (2017 + i) + '&quarter=' + (j + 1), last: 0 })
                        }
                    } else if (i + 2017 == year) {
                        for (var s = 0; s <= (month / 4); s++) {
                            if (s == Number.parseInt(month / 4)) {
                                childs.push({ name: year + '第' + (s + 1) + '季度', urls: 'dataReport.html?years=' + year + '&quarter=' + (s + 1), last: 1 })
                            } else {
                                childs.push({ name: year + '第' + (s + 1) + '季度', urls: 'dataReport.html?years=' + year + '&quarter=' + (s + 1), last: 0 })
                            }
                        }
                    }
                }
            }

            this.navs[0].child = childs;
        },
        yearPort: function() {
            var dates = new Date();
            var year = dates.getFullYear();
            var month = dates.getMonth() + 1;
            var childs = [];
            if (year >= 2017) {
                for (var i = 0; i <= (year - 2017); i++) {
                    if (i + 2017 < year) {
                        for (var j = 0; j < 2; j++) {
                            childs.push({ name: (2017 + i) + (j == 0 ? '上半年' : '全年'), urls: 'annalsdata.html?years=' + (2017 + i) + '-' + (j + 1), last: 0 })
                        }
                    } else if (i + 2017 == year) {
                        if (month > 6) {
                            childs.push({ name: year + '上半年', urls: 'annalsdata.html?years=' + year + '&quarter=1', last: 0 });
                            childs.push({ name: year + '全年年', urls: 'annalsdata.html?years=' + year + '&quarter=2', last: 1 })
                        } else {
                            childs.push({ name: year + '上半年', urls: 'annalsdata.html?years=' + year + '&quarter=1', last: 1 });
                        }

                    }
                }
            }

            this.navs[1].child = childs;
        },
    }

});